"Colin's taglist vimrc
"
"The taglist plugin can be downloaded from:
"http://www.geocities.com/yegappan/taglist/index.html

"Taglist options
"
"If Tlist is the only remaining window, exit (simplifies quiting)
let Tlist_Exit_OnlyWindow = 1

"
"Define functions (and handy commmands for them) to add Tlist and
"file explorer 'wings'
"

"Function to open a vertical file explorer
"Argument is used to specify if a vert resize should be done on the original
"  window.  Note: this is partially out of laziness for getting the original
"  WingsOfTagListAndFileExplorer() function to work with the vert resize.
function! OpenVerticalFileExplorer(resizeMiddle)
   set columns=104

   if v:version >= 700
      Vexplore!
   else
      "Open a vert file explorer on the right (preserving values of glbl var)
      let l:prevExplVertical = g:explVertical
      let l:prevExplStartRight = g:explStartRight
      let g:explVertical=1
      let g:explStartRight=1
      Sexplore
      let g:explVertical = l:prevExplVertical
      let g:explStartRight = l:prevExplStartRight
      "Make the file-explorer buffer unlisted
      set nobuflisted
   endif

   "Jump back to the main window
   wincmd W

   "If needed, resize main window to 80 columns
   if (a:resizeMiddle > 0)
      vertical resize 80
   endif
endfunction

"Function to pop out Tlist and file explorer 'wings'
"Argument is used to specify if gvim should be maximized
function! WingsOfTagListAndFileExplorer(size)

   "Start the taglist plugin
   Tlist
   "This makes taglist's display of current function more snappy
   set updatetime=1000

   call OpenVerticalFileExplorer(0)

   "Resize the window
   if (a:size > 0)
      set columns=162
      vertical resize 104
   else
      set columns=144
      vertical resize 80
   endif
   if (a:size >= 2)
      "Maximize vim
      simalt ~x
   endif
endfunction
command! Wings    call WingsOfTagListAndFileExplorer(0)
command! WingsBig call WingsOfTagListAndFileExplorer(1)
command! WingsMax call WingsOfTagListAndFileExplorer(2)

command! SideExplore call OpenVerticalFileExplorer(1)

"Warning - you need to be in the center editing pane for this to work right
function! RemoveWings()
   set updatetime=4000 "Return to default
   Tlist
   wincmd l
   close
   set columns=80
endfunction
command! NoWings call RemoveWings()

